package com.sp.reader;

import java.io.BufferedReader;
import java.io.FileReader;

public class BufferedReader_ {
    public static void main(String[] args) throws Exception {
        String filePath = "d:\\development\\code\\IO_Test\\news\\story.txt";
        //创建bufferedReader
        BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
        //读取
        String line;//按行读取, 效率高
        //1. bufferedReader.readLine()//按行读取文件
        //2. 当返回null时, 表示文件读取完毕
        while ((line = bufferedReader.readLine()) != null){
            System.out.println(line);
        }

        //关闭流, 这里只需要关闭BufferedReader, 因为底层会自动的去关闭流
        bufferedReader.close();
    }
}
